﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CarBooker.Repository;
using CarBooker.Models;

namespace CarBooker.Controllers
{
    public class HotelController : Controller
    {
        private IGenericRepository<Hotel> repository;
        public HotelController()
        {
            string conn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Code\GoogleCode\bookaca\branches\Phase1\CarBooker\App_Data\HotelBooker.mdf;Integrated Security=True;User Instance=True";
            repository = new HotelRepository(conn);
        }
        //
        // GET: /Hotel/

        public ActionResult Index()
        {
            return View(repository.List);
        }
        public ActionResult Create()
        {
            return View();
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([Bind(Exclude = "Id")]Hotel hotelToCreate)
        {
            try
            {
                repository.Create(hotelToCreate);
                return RedirectToAction("Index");
            }
            catch 
            {
                return View();
            }
        }


    }
}
